package com.bckj.fastboot.upms.biz.controller;

import com.bckj.fastboot.core.lang.model.PageResult;
import com.bckj.fastboot.core.page.PageSupport;
import com.bckj.fastboot.upms.api.dto.SysDictQuery;
import com.bckj.fastboot.upms.api.dto.SysDictRequest;
import com.bckj.fastboot.upms.api.entity.SysDict;
import com.bckj.fastboot.upms.api.service.SysDictRemoteService;
import com.bckj.fastboot.upms.api.vo.SysDictVO;
import com.bckj.fastboot.upms.biz.service.SysDictService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;


/**
 * 字典管理
 *
 * @author wfc
 * @since 2023-06-03 22:42:05
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("sysDict")
public class SysDictController implements SysDictRemoteService {

	private final SysDictService sysDictService;

	@Override
	public PageResult<SysDictVO> page(SysDictQuery query) {
		var page = PageSupport.page(() -> sysDictService.findAll(query));
		return PageResult.of(page);
	}

	@Override
	public boolean save(SysDictRequest request) {
		return sysDictService.save(request);
	}

	@Override
	public boolean update(SysDictRequest request) {
		return sysDictService.update(request);
	}

	@Override
	public SysDictVO details(Long id) {
		return sysDictService.details(id);
	}

	@Override
	public boolean enabled(Long id) {
		return sysDictService.enabled(id);
	}

	@Override
	public boolean remove(Long id) {
		return sysDictService.remove(id);
	}

	@Override
	public List<SysDict> listByType(String type) {
		return sysDictService.listByType(type);
	}
}

